<template>
  <div class="dashboard-editor-container">

    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <raddar-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <bar-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="24">
        <div class="chart-wrapper">
          <user-buy-chart />
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import UserBuyChart from '@/views/dashboard/admin/components/UserBuyChart'

const lineChartData = {
  pv: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [9041187, 8842933, 9210821, 9358998, 9718959, 12329644, 12237300]
  },
  buy: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [226835, 212000, 223072, 221463, 210016, 257907, 257757]
  },
  cart: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [541904, 534157, 551593, 565015, 623346, 793569, 774905]
  },
  fav: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [291221, 289100, 298587, 302264, 307115, 396749, 392197]
  }
}

export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart,
    UserBuyChart
  },
  data() {
    return {
      lineChartData: lineChartData.pv
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
